﻿using System;
using System.Collections.Specialized;
using UFSoft.UBF.UI.IView;

namespace UFIDA.U9.Cust.Pub.WSLogUI
{
    public static class WSLogUIHelper
    {
        #region 选择日期

        /// <summary>
        ///     选择日期的默认值
        /// </summary>
        public const string SelectDateDefaultValueSymbol = "WSLog_SelectDateDefaultValue";

        /// <summary>
        ///     选择日期的结果值
        /// </summary>
        public const string SelectDateResultValueSymbol = "WSLog_SelectDateResultValue";

        /// <summary>
        ///     显示选择日期的窗口
        /// </summary>
        public static void ShowSelectDateWin(IPart wePart, DateTime defaultDate)
        {
            const string formID = "5a3eaf8f-4e72-4cb3-8de6-921fb83f214c";
            NameValueCollection param = new NameValueCollection();
            if (defaultDate != DateTime.MinValue)
                wePart.CurrentState[SelectDateDefaultValueSymbol] = defaultDate;
            wePart.ShowAtlasModalDialog(formID, "选择日期", "315", "195", null, param, false, false,
                false);
        }

        /// <summary>
        ///     获取返回选择日期
        /// </summary>
        /// <param name="wePart"></param>
        /// <returns></returns>
        public static DateTime GetReturnSelectDate(IPart wePart)
        {
            if (wePart.CurrentState[SelectDateResultValueSymbol] == null) return DateTime.MinValue;
            DateTime date = DateTime.Parse(wePart.CurrentState[SelectDateResultValueSymbol].ToString());
            wePart.CurrentState[SelectDateResultValueSymbol] = null;
            return date;
        }

        #endregion
    }
}